Skip to content

Grep matches literal line endings in indexed source - #1439

Merged
zlareb1 merged 4 commits into
mainfrom
fix/grep-line-ending-literals
Nov 25, 2026
Merged

zlareb1 merged 4 commits into
mainfrom
fix/grep-line-ending-literals

Conversation

@zlareb1

@zlareb1 zlareb1 commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Changelog category

  • Bug Fix

Changelog entry

Grep matches exact LF and CRLF terminators in indexed lines and preserves those matches when prioritizing literal alternatives.

Why

Grep stripped line endings before matching literals and excluded any literal with a newline from first-page prioritization. A batch could return only generic hits even when an exact, line-terminated alternative matched indexed tests.

Scope and risk

Match a terminal newline against retained physical source in both the first scan and the fallback scan for uncovered alternatives. Verify the coordinate against the LF count from the same indexed file revision. This rejects artificial line endings on the tail of an oversized slice. Projected notebook and reference text keeps ordinary literal matching. Physical-only searches skip ineligible chunks before the pool limit. Source recovery carries the verified line count to raw chunks at the same revision. Ordinary literals use the direct substring check. Match text excludes the terminator.

Compatibility, rollout and rollback

  • Wire. Existing request and response fields.
  • Operator steps. None.
  • Rollback. Revert this change. The index and stored source are unchanged.

Tests

  • Seven source-coordinate integration cases pass. They exercise matches in the first result pool and the fallback scan, cursor ordering, LF and CRLF, projected source, recovery from nested skeletons, and a file without a final terminator.
  • Replayed the recorded literal batch against both index tiers. The previously omitted alternative has five verified lines on the first page. Searching for that literal alone returns all eleven matching fixture lines.
  • Replayed oversized parsed and fallback chunks with and without source terminators. Both scans return only the terminated files.
  • Lint, formatting and type checks pass.

AI assistance in the code

  • AI-generated with Codex. Checked retained coordinates and ClickHouse fallback witnesses against the source revision.
  • I can explain every line of this diff and how it interacts with the rest of Loom.

Checklist

  • Local format, lint and type checks for this change pass. Focused integration tests pass.
  • Documentation covers exact line endings.
  • Commits are signed off.

Keep retained terminators for exact alternatives that request them, including the fallback scan for an uncovered literal.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@vercel

vercel Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
loom-docs Ready Ready Preview Nov 25, 2026 9:11am UTC
loom-telemetry Ready Ready Preview Nov 25, 2026 9:11am UTC

Request Review

Use the indexed file line count at the same revision to distinguish a real line feed from a synthetic one. Keep ordinary literals on the direct substring path.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Use live file metadata from the same revision for each line and keep projected excerpts on ordinary literal matching.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
Filter projected chunks out of ending-only pools and carry the same file revision proof through skeleton recovery.

Signed-off-by: Lareb Zafar <lareb.zafar@clickhouse.com>
@zlareb1
zlareb1 merged commit 019bf10 into main Nov 25, 2026
49 of 76 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant